# -*- coding: utf-8 -*-

from django.core.management.base import BaseCommand, CommandError
from optparse import make_option
import os,sys

pathname, scriptname =  os.path.split(sys.argv[0])
_ROOT = os.path.abspath(pathname)

class Command(BaseCommand):

    keys = ["prod", "stage", "dev", "test"]
    args = 'prod, stage, test, dev'
    help = 'Execute configuration'

    #option_list = BaseCommand.option_list + (
    #    make_option('--delete',
    #        action='store_true',
    #        dest='delete',
    #        default=False,
    #        help='Delete poll instead of closing it'),
    #    )

    def handle(self, *args, **options):


        if len(args)==1 and args[0] in self.keys:
            for key in self.keys:
                if os.path.exists( os.path.join(_ROOT, ".%s" % key ) ):
                    os.remove( os.path.join(_ROOT, ".%s" % key ) )

            f = file( os.path.join(_ROOT, ".%s" % args[0] ), "w")
            f.close()
        else:
            raise CommandError('Select argument from <prod, stage, dev, test>')



